# $Id$
# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=mysql
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-${_realname}")
pkgver=1.2.5
pkgrel=2
pkgdesc="MySQL support for Python (mingw-w64)"
arch=(any)
url="http://mysql-python.sourceforge.net/"
license=('GPL2')
depends=("${MINGW_PACKAGE_PREFIX}-python2" "${MINGW_PACKAGE_PREFIX}-libmariadbclient")
makedepends=("${MINGW_PACKAGE_PREFIX}-python2-setuptools")
source=("https://pypi.python.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-${pkgver}.zip"
        fix-mingw.patch)
sha256sums=('811040b647e5d5686f84db415efd697e6250008b112b6909ba77ac059e140c74'
            '201092ebbff2ef49e4c422e59131b377688ea70801b38c247ddd156ae8413cff')

prepare() {
  cd MySQL-python-${pkgver}
  patch -p1 -i ${srcdir}/fix-mingw.patch
  cd ..
  cp -rf MySQL-python-${pkgver} python2-${MINGW_CHOST}
  local _win_prefix=$(cygpath -wm ${MINGW_PREFIX})
  echo "connector = ${_win_prefix}" >> python2-${MINGW_CHOST}/site.cfg
}

build() {
  cd ${srcdir}/python2-${MINGW_CHOST}
  ${MINGW_PREFIX}/bin/python2 setup.py build
}

package() {
  cd "${srcdir}/python2-${MINGW_CHOST}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
}
